package net.bwie.realtime.jtp.Rpfunction;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import net.bwie.realtime.jtp.bean.Order;
import org.apache.flink.api.common.functions.RichMapFunction;

/**
 * 简介说明:
 *
 * @author: LiLi
 * @date: 2025/05/28 11:02:36
 * @version: 1.0
 */
public class JdApiMapFunction extends RichMapFunction<String, Order> {
    @Override
    public Order map(String value) throws Exception {
        JSONObject jsonObject = JSON.parseObject(value);
        return new Order(
                jsonObject.getString("orderId"),
                jsonObject.getInteger("userId"),
                jsonObject.getInteger("itemId"),
                jsonObject.getString("itemName"),
                jsonObject.getString("category"),
                jsonObject.getLongValue("price"),
                jsonObject.getInteger("quantity"),
                jsonObject.getLongValue("payment"),
                jsonObject.getLongValue("discount"),
                jsonObject.getString("province"),
                jsonObject.getString("city"),
                jsonObject.getString("promotionId"),
                jsonObject.getLongValue("timestamp")
        );
    }
}
